package com.budwk.app.sqfw.controllers.admin;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.budwk.app.sqfw.enums.RectificationStatusEnum;
import com.budwk.app.sqfw.services.WasteClassificationService;
import com.budwk.app.sqfw.vo.Sqfw_formSummaryForAdminVO;
import com.budwk.starter.common.openapi.annotation.ApiDefinition;
import com.budwk.starter.common.openapi.annotation.ApiFormParams;
import com.budwk.starter.common.openapi.annotation.ApiOperation;
import com.budwk.starter.common.openapi.annotation.ApiResponses;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.log.annotation.SLog;
import lombok.extern.slf4j.Slf4j;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.*;

/**
 * 垃圾分类
 */

@IocBean
@At("/platform/sqfw/wasteClassification")
@ApiDefinition(tag = "垃圾分类巡查记录接口")
@Slf4j
public class WasteClassificationController {

    @Inject
    private WasteClassificationService wasteClassificationService;

    /**
     * 垃圾分类巡查记录表列表数据（用于后台管理系统）
     */
    @At()
    @Ok("json")
    @POST
    @ApiOperation(name = "垃圾分类巡查记录表列表数据")
    @ApiFormParams(implementation = Sqfw_formSummaryForAdminVO.class)
    @ApiResponses(implementation = Sqfw_formSummaryForAdminVO.class)
    @SaCheckLogin
    public Result<?> listWasteClassification(@Param("..") Sqfw_formSummaryForAdminVO forAdmin) {
        return wasteClassificationService.listWasteClassification(forAdmin);
    }

    @At()
    @Ok("json")
    @GET
    @ApiOperation(name = "整改状态(枚举，枚举项：全部 / 正常 / 已整改 / 未整改)")
    @SaCheckLogin
    public Result<?> listRectificationStatus() {
        return Result.data(RectificationStatusEnum.listNames());
    }

    @At()
    @Ok("json")
    @POST
    @ApiOperation(name = "查询导出：按照条件导出PDF,根据服务记录id数组生成pdf合集zip")
    @ApiFormParams(implementation = Sqfw_formSummaryForAdminVO.class)
    @SaCheckLogin
    public Result<?> queryExportDataPDF(@Param("..") Sqfw_formSummaryForAdminVO bean) {
        // 检查权限
        String pdfUrl = wasteClassificationService.queryExportDataPDF(bean);
        return Result.data(pdfUrl);
    }

    @At()
    @Ok("json")
    @POST
    @ApiOperation(name = "查询导出：按照条件导出excel, 根据服务记录id和汇总Id数组生成Excel合集")
    @ApiFormParams(implementation = Sqfw_formSummaryForAdminVO.class)
    @SLog(tag = "查询导出：按照条件导出excel, 根据服务记录id数组和汇总Id生成Excel合集", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> queryExportDataExcel(@Param("..") Sqfw_formSummaryForAdminVO bean) {
        // 检查权限
        bean.setType("垃圾分类");
        String url = wasteClassificationService.queryExportDataExcel(bean);
        return Result.data(url);
    }
}
